package homework.week3.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * 窗体，最基本的显示组件，顶层组件
 */
public class Window implements IContainer {

    /**
     * 窗体所包含组件集合体
     */
    private final List<IContainer> items = new ArrayList<>();

    /**
     * 窗体组件标题
     */
    private String title;

    /**
     * 组件宽
     */
    private int width;

    /**
     * 组件高
     */
    private int height;

    /**
     * 是否隐藏
     */
    private boolean hidden;

    /**
     * 组件等级，窗体默认0，最大，依次递增
     */
    private Integer level;

    /**
     * 窗体构造函数
     *
     * @param title  标题
     * @param width  宽
     * @param height 高
     * @param hidden 是否隐藏
     * @param level  等级
     */
    public Window(String title, int width, int height, boolean hidden, Integer level) {
        this.title = title;
        this.width = width;
        this.height = height;
        this.hidden = hidden;
        this.level = level;
    }

    @Override
    public String getContainerName() {
        return this.title;
    }

    @Override
    public void add(IContainer iContainer) {
        this.items.add(iContainer);
    }

    @Override
    public void remove(IContainer iContainer) {
        this.items.remove(iContainer);
    }

    @Override
    public int getWidth() {
        return this.width;
    }

    @Override
    public int getHeight() {
        return this.height;
    }

    @Override
    public boolean hidden() {
        return this.hidden;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public boolean isHidden() {
        return hidden;
    }

    public void setHidden(boolean hidden) {
        this.hidden = hidden;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    @Override
    public int level() {
        return getLevel();
    }

    @Override
    public boolean isContainer() {
        return true;
    }

    @Override
    public List<IContainer> getItems() {
        return this.items;
    }
}
